package com.heyqing.topic.NumberOfPoints_2848;

import java.util.*;

/**
 * ClassName:NumberOfPoints
 * Package:com.heyqing.topic.NumberOfPoints_2848
 * Description:
 *
 * @Date:2024/9/15
 * @Author:Heyqing
 */
public class NumberOfPoints {
    public int numberOfPoints(List<List<Integer>> nums) {
        Set<Integer> res = new HashSet<>();
        for (List<Integer> num : nums) {
            Integer start = num.get(0);
            Integer end = num.get(1);
            for (int i = start; i <= end; i++) {
                res.add(i);
            }
        }
        return res.size();
    }

    public static void start() {
        NumberOfPoints numberOfPoints = new NumberOfPoints();
        List<List<Integer>> nums = new ArrayList<>();
        System.out.println("数组数量：");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            List<Integer> num = new ArrayList<>();
            System.out.print("第" + (i + 1) + "个（0）：");
            num.add(sc.nextInt());
            System.out.print("第" + (i + 1) + "个（1）：");
            num.add(sc.nextInt());
            nums.add(num);
        }
        int res = numberOfPoints.numberOfPoints(nums);
        System.out.println(res);
    }
}
